package sharedpreferences.birthday.example;

import sharedpreferences.birthday.example.R;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.DatePicker;

public class PideCumpleActivity extends Activity implements OnClickListener {
    private DatePicker vFecha;
	private View vOk;

	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pide_cumple);
        
        vFecha = (DatePicker) findViewById(R.id.Fecha);
        vOk = findViewById(R.id.Ok);
        vOk.setOnClickListener(this);
    }

	@Override
	public void onClick(View arg0) {
		
		String fecha = vFecha.getDayOfMonth() + "-" + vFecha.getMonth() + "-" + vFecha.getYear();
		
		SharedPreferences prefs = getSharedPreferences("MisPrefs", Activity.MODE_PRIVATE); 
		Editor editor = prefs.edit();
		editor.putString("fecha_cumple", fecha);
		editor.commit();
		//create a new intent with the shared prefernce and start the other activity
		Intent i = new Intent();
		i.setClass(PideCumpleActivity.this, VerCumpleActivity.class);
		startActivity(i);
	}
}